import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url';

const target = 'http://112.54.164.78:8080'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(),],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
  server:{
    allowedHosts:['localhost'],
    port:5173,
    proxy:{
      '/api':{
        target,
        changeOrigin:true,
        bypass(req) {
          req.headers.Referer = target;
          req.headers.Origin = target;
        },
      },
      '/public':{
        target,
        changeOrigin:true,
        bypass(req) {
          req.headers.Referer = target;
          req.headers.Origin = target;
        },
      },
      '/user':{
        target,
        changeOrigin:true,
        bypass(req) {
          req.headers.Referer = target;
          req.headers.Origin = target;
        },
      }
    }
  }
})
